package com.yqg.protection.listenern;

import cn.hutool.core.bean.BeanUtil;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.yqg.protection.controller.dto.ImportFireBasicInforDto;
import com.yqg.protection.entity.FireBasicInfor;
import com.yqg.protection.mapper.FireBasicInforMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * projectName:xf-service1
 * author:zxf
 * time:2024/10/16 15:16
 * description:
 */
@Component
public class FireBasicInforListener extends AnalysisEventListener<ImportFireBasicInforDto> {

    @Autowired
    private FireBasicInforMapper fireBasicInforMapper;

    @Override
    public void invoke(ImportFireBasicInforDto importFireBasicInforDto, AnalysisContext analysisContext) {
        FireBasicInfor fireBasicInfor = new FireBasicInfor();
        BeanUtil.copyProperties(importFireBasicInforDto, fireBasicInfor, true);
        fireBasicInfor.setIsDelete(0);
        fireBasicInforMapper.insert(fireBasicInfor);
    }

    @Override
    public void doAfterAllAnalysed(AnalysisContext analysisContext) {

    }
}
